package com.bdqn.zhang.service.impl;

import com.bdqn.zhang.entity.User;
import com.bdqn.zhang.service.BaseService;
import com.bdqn.zhang.service.StartService;
import com.bdqn.zhang.utils.ServiceFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class StartServiceImpl implements StartService {

    // 共享数据
    // 用户集合
    public static List<User> users = new ArrayList<User>();

    static {

        users.add(new User("admin","123"));
        users.add(new User("root","456"));
        users.add(new User("ry","ry"));
    }

    //Map<String,User>

    @Override
    public void execute() {
        Scanner sc = new Scanner(System.in);
        System.out.println("欢迎使用书虫阅读器");
        while (true){
            System.out.println("1、登录");
            System.out.println("2、注册");
            System.out.println("3、退出");
            System.out.println("请选择");
            int choice = sc.nextInt();
            switch (choice){
                case 1:
                    System.out.println("-----登录------");
                    BaseService baseService = ServiceFactory.getService("login");
                    baseService.execute();
                    break;
                case 2:
                    System.out.println("-----注册------");
                    break;
                case 3:
                    System.exit(0);
                default:
                    System.out.println("输入有误");
            }

        }
    }
}
